//: Playground - noun: a place where people can play

import UIKit



func addTo(_ adder: Int) -> (Int) -> Int {
    return { num in
        return num + adder
    }
}

func LetterSortArray(stringArr: [[String]]) -> [AnyObject] {
    //    let tempArray = ReturnSortChineseArrar(stringArr)
    var LetterResult : Array<Array<String>> = []
    var item = [String]()
    var tempString: String?
    for object in strArrays {
        let pin = object[1]
        if tempString != pin {
            item.removeAll()
            item.append(object[0])
            LetterResult.append(item)
            tempString = pin
        } else {
            //            item.insert(object.strings, atIndex: item.count)
            LetterResult[LetterResult.count-1].append(object[0])
            //            item.append(object[0])
        }
    }
    return LetterResult as [AnyObject]
}


let strArrays = [["啥都w是","S"],["啥都e是","S"],["张是","Z"],["张王","Z"],["李是","L"],["李都","L"],["胡孙","H"],["胡老","H"],["韩语","H"],["韩笑","H"],["来是","L"]]
// 给常量 绑定方法
let d = addTo(10)
let s = d(2)

// 数组排序
strArrays.count
let array = strArrays.sorted(by: {$0[1] < $1[1]})
array

let a = LetterSortArray(stringArr: array)
a.count

var arr = [1,2,3,4,5].reduce([Int]()) { $0 + [$1] }

arr


// 定义 符号方法
var dic = ["1":"11","2":"22"]
var dics = ["1":"11","2":"22","3":"33"]
var arraydics = [["name":"1","id":"d1"],["name":"2","id":"d2"],["name":"2","id":"d2"],["name":"3","id":"d3"],["name":"4","id":"d4"],["name":"5","id":"d5"]]

infix operator <-
infix operator <<-

func <- <K, V> ( left: inout Dictionary<K, V>, right: Dictionary<K, V>) {
    right.forEach({left.updateValue($0.value, forKey: $0.key)})
}

dic <- dics

dic

dics

var arrss = ["Chris","Apple","Bady","Wifi"]

//标准的闭包表达式
arrss.sort(by: { (s1:String, s2:String) -> Bool in
    return s1 < s2
})


//获取当前时间
let now = Date()

// 创建一个日期格式器
let dformatter = DateFormatter()
dformatter.dateFormat = "yyyy年MM月dd日 HH:mm:ss"
print("当前日期时间：\(dformatter.string(from: now))")

//当前时间的时间戳
let timeInterval:TimeInterval = now.timeIntervalSince1970
let timeStamp = Int(timeInterval)
print("当前时间的时间戳：\(timeStamp)")


var arrssss = [1,2,3,4,5,6,7,8]

var arrssss1 = [1,2,3,4,5,6,7,8]
//arrssss.removeLast(2)
arrssss1.removeFirst(3)
arrssss.dropFirst(3)
//arrssss.removeSubrange(Range(NSRange(location: 0, length: 3))!)
print("The current array is: \(arrssss1)-----\(arrssss)")

let price = "1314"
let zhi = Double(price)
let numbb = String(format: "%.1f", zhi!/10000)





